// extensions/CommentHighlight.js
import { Mark } from '@tiptap/core'

export const CommentHighlight = Mark.create({
  name: 'commentHighlight',
  addOptions() {
    return {
      HTMLAttributes: {
        class: 'comment-highlight',
      },
    }
  },
  addAttributes() {
    return {
      commentId: {
        default: null,
        // 从 HTML 中解析 data-comment-id
        parseHTML: element => element.getAttribute('data-comment-id'),
        // 渲染为 data-comment-id 属性
        renderHTML: attributes => ({
          'data-comment-id': attributes.commentId,
        }),
      },
    }
  },
  parseHTML() {
    return [
      {
        tag: 'span[data-comment-id]',
        getAttrs: dom => ({
          commentId: dom.getAttribute('data-comment-id'),
        }),
      },
    ]
  },
  renderHTML({ HTMLAttributes }) {
    return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]
  },

  // 在 
})